//
//  RootTabBarController.m
//  Computer
//
//  Created by qianfeng on 15/10/20.
//  Copyright © 2015年 qianfeng. All rights reserved.
//

#import "RootTabBarController.h"
//导入自定义Navigation视图控制器
#import "RootNavigationController.h"
//导入自定义的viewController
#import "RootViewController.h"
//导入header
#import "Header.h"
@interface RootTabBarController ()

@end

@implementation RootTabBarController
{
    //定义全局数组，添加四个根视图
    NSMutableArray *_vcArray;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    //调用创建视图控制器的方法
    [self createViewControllers];
}
//创建4个控制器
-(void)createViewControllers{
    //初始化数组
    _vcArray = [[NSMutableArray alloc]initWithCapacity:4];
    for (int i = 0; i < 4; i++) {
        //动态创建4个根视图，全局用其他父视图接受
        RootViewController *rvc = [[NSClassFromString([VC_ARRAY objectAtIndex:i]) alloc]initWithTitle:[NAVIGATION_TITLE objectAtIndex:i] tabTitle:[TABBAR_TITLE objectAtIndex:i] tabImage:[TABBAR_IMAGE objectAtIndex:i]];
        //根据RootViewController创建RootNavigationController
        RootNavigationController *rnvc = [[RootNavigationController alloc]initWithRootViewController:rvc];
        //放到数组中
        [_vcArray addObject:rnvc];
    }
    //设置RootTabBarController VC
    self.viewControllers = _vcArray;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
